#!/usr/bin/env python
# -*- coding: utf-8 -*-


'''
key ::= row-key column-family column-qualifier flag timestamp
flag ::= DELETE_ROW | DELETE_COLUMN_FAMILY | DELETE_CELL | INSERT

DELETE_ROW           ::= 0x00
DELETE_COLUMN_FAMILY ::= 0x01
DELETE_CELL          ::= 0x02
INSERT               ::= 0xFF
'''

from bisect import bisect, insort, bisect_left,bisect_right

def test1() :
    haystack = []
    for needle in ('foo', 'bar', 'baz', 'bar') :
        insort(haystack, needle)
        print haystack

    for needle in ('foo', 'bar', 'baz') :
        index_left  = bisect_left(haystack, needle)
        index_right = bisect_right(haystack, needle)
        index = bisect(haystack, needle)
        print needle,index_left,index_right,index

    needle = 'ba'
    index = bisect(haystack, needle)
    print needle,index
    # test1()

#######################################################################

if __name__ == '__main__' :
    test1()


